package ch.mse.android.starbucksfinder.helper;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import ch.mse.android.starbucksfinder.Command;

public class MessageHelper {
	public static AlertDialog displayModalMessage(Context ctx, String title, String message) {
		final Context mainContext = ctx;
		final AlertDialog msg = new AlertDialog.Builder(mainContext).create();
		msg.setTitle(title);
		msg.setMessage(message);		
		msg.show();
		return msg;
	}
	public static void displayAlertMessage(Context ctx, String title, String message) {
		displayAlertMessage(ctx, title, message, null);
	}
	
	public static void displayAlertMessage(Context ctx, String title, String message,final Command cmd) {
		final Context mainContext = ctx;
		final AlertDialog msg = new AlertDialog.Builder(mainContext).create();
		msg.setTitle(title);
		msg.setMessage(message);
		msg.setButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				msg.hide();
				if(cmd!=null)
					cmd.perform();
			}
		});
		msg.show();
	}
}
